package com.zlict.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zlict.common.annotation.Log;
import com.zlict.common.core.controller.BaseController;
import com.zlict.common.core.domain.AjaxResult;
import com.zlict.common.enums.BusinessType;
import com.zlict.admin.domain.RdIntangibleAssets;
import com.zlict.admin.service.IRdIntangibleAssetsService;
import com.zlict.common.utils.poi.ExcelUtil;
import com.zlict.common.core.page.TableDataInfo;

/**
 * 无形资产管理
 * 
 * @author lqh
 * @date 2025-06-11
 */
@RestController
@RequestMapping("/assets/intangibleAssets")
@RequiredArgsConstructor
public class RdIntangibleAssetsController extends BaseController
{
    private final IRdIntangibleAssetsService rdIntangibleAssetsService;

    /**
     * 查询资产管理-无形资产列表(分页)
     */
//    @PreAuthorize("@ss.hasPermi('assets:intangibleassets:list')")
    @GetMapping("/list")
    public TableDataInfo list(RdIntangibleAssets rdIntangibleAssets)
    {
        startPage();
        List<RdIntangibleAssets> list = rdIntangibleAssetsService.selectRdIntangibleAssetsList(rdIntangibleAssets);
        return getDataTable(list);
    }

    /**
     * 导出资产管理-无形资产列表
     */
//    @PreAuthorize("@ss.hasPermi('assets:intangibleassets:export')")
    @Log(title = "资产管理-无形资产", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RdIntangibleAssets rdIntangibleAssets)
    {
        List<RdIntangibleAssets> list = rdIntangibleAssetsService.selectRdIntangibleAssetsList(rdIntangibleAssets);
        ExcelUtil<RdIntangibleAssets> util = new ExcelUtil<RdIntangibleAssets>(RdIntangibleAssets.class);
        util.exportExcel(response, list, "资产管理-无形资产数据");
    }

    /**
     * 获取资产管理-无形资产详细信息
     */
//    @PreAuthorize("@ss.hasPermi('assets:intangibleassets:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(rdIntangibleAssetsService.selectRdIntangibleAssetsById(id));
    }

    /**
     * 新增资产管理-无形资产
     */
//    @PreAuthorize("@ss.hasPermi('assets:intangibleassets:add')")
    @Log(title = "资产管理-无形资产", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RdIntangibleAssets rdIntangibleAssets)
    {
        return toAjax(rdIntangibleAssetsService.insertRdIntangibleAssets(rdIntangibleAssets));
    }

    /**
     * 修改资产管理-无形资产
     */
//    @PreAuthorize("@ss.hasPermi('assets:intangibleassets:edit')")
    @Log(title = "资产管理-无形资产", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RdIntangibleAssets rdIntangibleAssets)
    {
        return toAjax(rdIntangibleAssetsService.updateRdIntangibleAssets(rdIntangibleAssets));
    }

    /**
     * 删除资产管理-无形资产
     */
//    @PreAuthorize("@ss.hasPermi('assets:intangibleassets:remove')")
    @Log(title = "资产管理-无形资产", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rdIntangibleAssetsService.deleteRdIntangibleAssetsByIds(ids));
    }

    /**
     * 查询资产管理-无形资产列表
     */
//    @PreAuthorize("@ss.hasPermi('assets:intangibleassets:getList')")
    @GetMapping("/getList")
    public AjaxResult getList(RdIntangibleAssets rdIntangibleAssets)
    {
        List<RdIntangibleAssets> list = rdIntangibleAssetsService.selectRdIntangibleAssetsList(rdIntangibleAssets);
        return success(list);
    }

    /**
     * 无形资产摊销明细
     */
    @GetMapping("/getDepreciationList")
    public AjaxResult getDepreciationList(Long id) {
        return success(rdIntangibleAssetsService.selectRdAssetsAmortizationDetailById(id));
    }
    /**
     * 批量启用
     */
    @PostMapping("/batchEnable")
    public AjaxResult batchEnable(@RequestBody Long[] ids) {
        return success(rdIntangibleAssetsService.batchEnable(ids));
    }

    /**
     * 批量禁用
     */
    @PostMapping("/batchDisable")
    public AjaxResult batchDisable(@RequestBody Long[] ids) {
        return success(rdIntangibleAssetsService.batchDisable(ids));
    }
}
